import 'package:dmz/base/pageWidget/base_stateful_widget.dart';
import 'package:dmz/base/widget/defult_widget.dart';
import 'package:dmz/base/widget/keep_alive_wrapper.dart';
import 'package:dmz/business/home/model/moto_model.dart';
import 'package:dmz/business/mine/widget/garage_accept_wdget.dart';
import 'package:dmz/business/mine/widget/garage_main_widget.dart';
import 'package:dmz/business/mine/widget/garage_share_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

class GarageWidgets {
  static garageMainTopWidget(
      int select, Function(int) click, Function() ringhtClick) {
    List<String> titles = ['车库'.tr, '分享'.tr, '接受'.tr];
    item(title, tag, select) {
      return Container(
          alignment: Alignment.center,
          width: 152.sp,
          child: Column(children: [
            Container(
                alignment: Alignment.center,
                height: 88.sp,
                child: DefaultText(title, select ? 36.sp : 28.sp,
                    textColor: select
                        ? const Color(0xFF23C565)
                        : const Color(0xFF8F8F8F),
                    fontWeight: select ? FontWeight.w700 : FontWeight.normal)),
            Container(
                height: 3.sp,
                color: select ? const Color(0xFF23C565) : Colors.transparent)
          ]));
    }

    return Container(
        alignment: Alignment.center,
        child: Row(crossAxisAlignment: CrossAxisAlignment.center, children: [
          Container(
                  child: Image.asset('assets/images/login/back_icon.png',
                          width: 34.sp, height: 38.sp)
                      .marginOnly(right: 32.sp, left: 32.sp))
              .addGestureDetector(() => Get.back()),
          Expanded(
              child: Row(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: List.generate(
                      titles.length,
                      (index) => item(titles[index], index, select == index)
                          .addGestureDetector(() => click(index))))),
          Image.asset('assets/images/user/add_image.png',
                  width: 88.sp, height: 88.sp)
              .marginOnly(left: 32.sp, right: 32.sp)
              .addGestureDetector(() => ringhtClick())
        ])).marginOnly(top: Get.mediaQuery.padding.top);
  }

  static contentWidget(
      List<MotoModel> motoList, int selectIndex, PageController controller) {
    return KeepAliveWrapper(
        child: PageView(controller: controller, children: [
      MainWidget(motoList: motoList, selectIndex: selectIndex),
      const ShareWidget(),
      const AcceptWdiegt(),
    ]));
  }

  static Widget emptyWidget() {
    return Column(mainAxisAlignment: MainAxisAlignment.center, children: [
      Image.asset('assets/images/user/empty_image.png',
          width: 275.sp, height: 448.sp),
      DefaultText('对不起，目前没有数据'.tr, 32.sp, textColor: Color(0xB3FFFFFF))
          .marginOnly(top: 32.sp)
    ]).marginOnly(bottom: 200.sp);
  }
}
